package com.yhq.spring.event.annotation;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author hqyin
 * @date 2023/3/13 3:04 下午
 */
@Component
@Slf4j
public class CommonEventListener {
   @EventListener(condition = "#commonEvent.type == 'add'")
    public void add(CommonEvent commonEvent) {
        log.info("receive add event：{}", commonEvent.getMsgId());
        throw new RuntimeException("xxx");
    }

    @EventListener(condition = "#commonEvent.type== 'update'")
    public void update(CommonEvent commonEvent) {
        log.info("receive update event：{}", commonEvent.getMsgId());
    }

}
